<?php
/**
 * @author Mingming Tang iamalazyrat@gmail.com
 */

class Sign_Controller extends Base_Controller {

    public $restful = true;

    public function get_in() {
      $msg = Session::get('msg');
      return View::make('sign.in.main')->with('msg', $msg);
    }

    public function get_out() {
      Auth::logout();
      return Redirect::to('/sign/in');
    }

    public function post_auth() {
      $input = Input::all();
      if (!isset($input['password']) OR !isset($input['email'])) return Redirect::to('/sign/in')->with('msg', '用户名或密码为空');

      $credentials = array('username' => $input['email'], 'password' => $input['password']);

      if (Auth::attempt($credentials)){ 
        return Redirect::to('collection');
      } else {
        return Redirect::to('/sign/in')->with('msg', '用户名或密码不正确');
      }
    }
}

